package cn.rui.utils;

import java.util.Random;

/**
 * 随机生成salt
 * @author 徽州大都督
 * @date 2020/8/11
 */
public class SaltUtils {

    public static String getSalt(int n){
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()".toCharArray ();

        StringBuilder sb = new StringBuilder ();
        for (int i =0;i<n;i++){
            char c = chars[new Random ().nextInt (chars.length)];

            sb.append (c);
        }

        return sb.toString ();
    }

    public static void main(String[] args) {
        String salt = getSalt (4);
        System.out.println (salt);
    }
}
